﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Antu.WebControls;
using Antu.Core.Components;
using Antu.Core.Services;
using System.Web.UI.WebControls;
using EluZSProvider;
using System.Web;
using System.Data;

namespace WebSys.UI.Control.ZhengShou
{
    public class ProjectBJControl : MPBasicTemplate
    {
        EluZSDataProvider _EluZSDataProvider = (EluZSDataProvider)ProviderService.ProviderServiceMange.GetProvider("EluZSProvider");
        TextBox proName, proNo;
        CustomGridView CustomGridList1;
        Button search;
        CheckBox isBj;
        public string userid = string.Empty;
        protected override void OnLoad(EventArgs e)
        {
            if (HttpContext.Current.Session["UserID"] == null)
            {
                Antu.Utilities.UtilitiesPage.AlertDialogClear("登录超时，请重新登录！", "window.parent.location.href('../login.aspx');");
            }
            else
            {
                userid = HttpContext.Current.Session["UserID"].ToString();
            }
            InitControls();

            base.OnLoad(e);
            Bind();
        }

        protected void InitControls()
        {
            proName = (TextBox)FindControl("proName");
            proNo = (TextBox)FindControl("proNo");
            CustomGridList1 = (CustomGridView)FindControl("CustomGridList1");
            CustomGridList1.OnLoadData+=new EventHandler(CustomGridList1_OnLoadData);
            search = (Button)FindControl("search");
            search.Click += new EventHandler(search_Click);
            isBj = (CheckBox)FindControl("isBj");
        }

       

        protected void Bind()
        {
            string sqlwhere = string.Empty;
            if (!string.IsNullOrEmpty(proName.Text.Trim()))
            {
                sqlwhere += " and 项目名称 like '%"+proName.Text.Trim()+"%'";
            }
            if (!string.IsNullOrEmpty(proNo.Text.Trim()))
            {
                sqlwhere += " and 立项号 like '%" + proNo.Text.Trim() + "%'";
            }
            if (isBj.Checked == true)
            {
                sqlwhere += " and 报结状态 = '1'";
            }

            string sql = "Select ID,项目名称,立项号,(case when 报结状态 = 1 then '是' else '否' end ) 是否报结 from zs_project where 1=1 "+sqlwhere;
            DataTable dt = _EluZSDataProvider.GetTable(sql);
            CustomGridList1.DataSource = dt;
            CustomGridList1.RecordCount = dt.Rows.Count;
            CustomGridList1.DataBind();
        }

        protected void CustomGridList1_OnLoadData(object sender, EventArgs e)
        {
            Bind();
        }

        protected void search_Click(object sender, EventArgs e)
        {
            Bind();
        }
    }
}


